home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacWorld 1999 February
/
Macworld (1999-02).dmg
/
Cinema 4D GO demo
/
Plugin
/
Modeling
/
EqualTangents.cof
next >
Wrap
Text File
|
1998-03-16
|
1KB
|
57 lines
// EqualTangents
// set all selected points of an Hermite Spline to the
// same length, defined by the user
// (c) Christian Losch
// 1997 Maxon Computer GmbH
var len_vl,len_vr;
Function(doc)
{
var i,num,op,info,dlg,sp;
// allocate all data
info = new (SplineInfo); if (!info) return;
sp = new (SplinePoint); if (!sp) return;
dlg = new (SimpleDialog); if (!dlg) return;
// get active object
op = doc->FindFirstActiveObject(); if (!op || getclass(op)!=SplineObject) return;
op->GetSplineInfo(info);
if (info->type!=SPL_HERMITE)
{
TextDialog("No Hermite Spline");
return;
}
// user dialog
dlg->SetTitle("EqualTangents");
dlg->SetData(0,"Left" ,FIELD_FLOAT,0.0,1E6,len_vl);
dlg->SetData(1,"Right",FIELD_FLOAT,0.0,1E6,len_vr);
if (!dlg->DoDialog()) return;
len_vl = dlg->GetData(0);
len_vr = dlg->GetData(1);
// change tangents
num = op->GetPointNumber();
for (i=0; i<num; i++)
{
if (op->IsPointSelected(i) && op->GetPoint(i,sp))
{
sp->vl = vnorm(sp->vl)*len_vl;
sp->vr = vnorm(sp->vr)*len_vr;
op->SetPoint(i,sp);
}
}
op->UpdateObject();
doc->SendMessage(ACTIVE_OBJECT_CHANGED);
}
main()
{
len_vl = len_vr = 50.0;
RegisterMenuHook("Equal Tangents","Function");
}